var _initresourceId = "";
var _rootDir = "";
var _initDate = "";
var _httpUrl = "";
$(function(){
	_initresourceId=$("#initresourceId").val();
	_rootDir=$("#rootDir").val();
	_initDate=$("#initDate").val();
	_httpUrl = $("#httpUrl").val();
	//初始化图片上传编辑器
	var editorFile = new UE.ui.Editor({
		toolbars : [ [ 'insertimage' ] ],imageUrl : contextPath+'common/fileUpload/imageUp?prefix=logo&root='+_rootDir+'&id='+_initresourceId+"&dataFolder="+_initDate
		 ,imagePath:"/"
	});
	editorFile.render("filediv");
	editorFile.addListener('beforeInsertImage', function(t, arg) {
		var img = arg[0];
    	$("#smallimg").val(img.data_ue_src);
    	var imgasrc=_httpUrl + "/" +img.data_ue_src;
    	imgasrc="http://www.baidu.com/img/bdlogo.gif";
    	var str=$("#combo").html();
    	$(str).appendTo("#client_imgs").append("<img  width='180' height='108' src='"+imgasrc+"' />").show();

	});
	editorFile.ready(function() {
		// 设置选择按钮事件
		$("#recMarkImageUpload").click(function() {
			clickShoseFileUp();
		});
	});
	
});

/**
 * 
 * 点击双传图片 ，出文件选择对话框
 */
function clickShoseFileUp() {
	editor = UE.getEditor('filediv');
	var dialog = editor.getDialog("insertimage");
	dialog.open(); // 打开dialog
}
/**
 * 保存推荐标示
 */
function save(){
	$.messager.alert('保存','保存成功','info');
	closeAndRefresh();
}
/**
 * 取消新建
 */
function cancel(){
	closeAndRefresh();
}

/**
 * 关闭当前窗口，并刷新来源窗口
 */
function closeAndRefresh(){
	window.top.refreshSpecifiedTab(window.parent.recMarkTitle);
	window.top.closeCurrentTab(window.parent.getCurrentTagTitle());
}